package com.cleaningcloud.cld.controller;

import com.cleaningcloud.cld.domain.CldCalendar;
import com.cleaningcloud.cld.service.ICldCalendarService;
import com.cleaningcloud.cld.service.PublicCommonService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 通用公共方法Controller
 *
 * @author cleaningcloud
 * @date 2024-10-17
 */
@RestController
@RequestMapping("/common")
public class PublicCommonController extends BaseController {


    @Autowired
    private PublicCommonService service;

    @Autowired
    private ICldCalendarService cldCalendarService;

    /**
     * 选择项目岗位
     */
    @GetMapping("/selectedProjectJob/{level}")
    public AjaxResult selectedProjectJob(@PathVariable int level) {
        return success(service.selectedProjectJob(level));
    }


    /**
     * 选择项目 - 小组 - 人员
     */
    @GetMapping("/selectedProjectGroupStaff")
    public AjaxResult selectedProjectGroupStaff() {
        return success(service.selectedProjectGroupStaff());
    }


    /**
     * 根据项目id查询项目岗位及人员配置
     *
     * @param projectId
     * @return
     */
    @GetMapping("/selectJobStaffByProjectId/{projectId}")
    public AjaxResult selectJobStaffByProjectId(@PathVariable Long projectId) {
        return success(service.selectJobStaffByProjectId(projectId));
    }


    /**
     * 根据项目id查询项目小组及人员配置
     *
     * @param projectId
     * @return
     */
    @GetMapping("/selectGroupStaffByProjectId/{projectId}")
    public AjaxResult selectGroupStaffByProjectId(@PathVariable Long projectId) {
        return success(service.selectGroupStaffByProjectId(projectId, 1L));
    }

    /**
     * 获取今年节假日
     *
     * @param cldCalendar
     * @return
     */
    @GetMapping("/selectHolidays")
    public AjaxResult selectHolidays(CldCalendar cldCalendar) {
        return success(cldCalendarService.selectCldCalendarList(cldCalendar));
    }

}
